package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class DebtToTotalEquityRatio extends Equation {
	
	private double total_debt;
	private double total_equity;
	
	public DebtToTotalEquityRatio(){}
	
	public DebtToTotalEquityRatio( double totalDebt, double totalEquity )
	{
		this.total_debt = totalDebt;
		this.total_equity = totalEquity;
		value = ( total_debt / total_equity );
	}

	@Override
	public String getEquationName() {
		return EquationNames.DEBT_TO_TOTAL_EQUITY_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add(FieldList.TOTAL_DEBT);
		requiredFields.add(FieldList.TOTAL_EQUITY);
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		total_debt = values[0];
		total_equity = values[1];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( " + total_debt +" / " + total_equity +" ) = " + value; 
	}

	@Override
	public void solve() {
		value = ( total_debt / total_equity );
	}

	@Override
	public String getEquationString() {
		return "( " + FieldList.TOTAL_DEBT +" / " + FieldList.TOTAL_EQUITY +" )"; 
	}

}
